// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file DdsRecorderCommandTypeObjectSupport.cxx
 * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file
 *
 * This file was generated by the tool fastddsgen.
 */

#include "DdsRecorderCommandTypeObjectSupport.hpp"

#include <mutex>
#include <string>

#include <fastcdr/xcdr/external.hpp>
#include <fastcdr/xcdr/optional.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/dds/xtypes/common.hpp>
#include <fastdds/dds/xtypes/type_representation/ITypeObjectRegistry.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp>

#include "DdsRecorderCommand.hpp"


using namespace eprosima::fastdds::dds::xtypes;

// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_DdsRecorderCommand_type_identifier(
        TypeIdentifierPair& type_ids_DdsRecorderCommand)
{

    ReturnCode_t return_code_DdsRecorderCommand {eprosima::fastdds::dds::RETCODE_OK};
    return_code_DdsRecorderCommand =
        eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
        "DdsRecorderCommand", type_ids_DdsRecorderCommand);
    if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderCommand)
    {
        StructTypeFlag struct_flags_DdsRecorderCommand = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
                false, false);
        QualifiedTypeName type_name_DdsRecorderCommand = "DdsRecorderCommand";
        eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_DdsRecorderCommand;
        eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_DdsRecorderCommand;
        CompleteTypeDetail detail_DdsRecorderCommand = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderCommand, ann_custom_DdsRecorderCommand, type_name_DdsRecorderCommand.to_string());
        CompleteStructHeader header_DdsRecorderCommand;
        header_DdsRecorderCommand = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderCommand);
        CompleteStructMemberSeq member_seq_DdsRecorderCommand;
        {
            TypeIdentifierPair type_ids_command;
            ReturnCode_t return_code_command {eprosima::fastdds::dds::RETCODE_OK};
            return_code_command =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "anonymous_string_unbounded", type_ids_command);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_command)
            {
                {
                    SBound bound = 0;
                    StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
                    if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                            TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
                            "anonymous_string_unbounded", type_ids_command))
                    {
                        EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                            "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
                    }
                }
            }
            StructMemberFlag member_flags_command = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_command = 0x00000000;
            bool common_command_ec {false};
            CommonStructMember common_command {TypeObjectUtils::build_common_struct_member(member_id_command, member_flags_command, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_command, common_command_ec))};
            if (!common_command_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure command member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_command = "command";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_command;
            ann_custom_DdsRecorderCommand.reset();
            CompleteMemberDetail detail_command = TypeObjectUtils::build_complete_member_detail(name_command, member_ann_builtin_command, ann_custom_DdsRecorderCommand);
            CompleteStructMember member_command = TypeObjectUtils::build_complete_struct_member(common_command, detail_command);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderCommand, member_command);
        }
        {
            TypeIdentifierPair type_ids_args;
            ReturnCode_t return_code_args {eprosima::fastdds::dds::RETCODE_OK};
            return_code_args =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "anonymous_string_unbounded", type_ids_args);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_args)
            {
                {
                    SBound bound = 0;
                    StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
                    if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                            TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
                            "anonymous_string_unbounded", type_ids_args))
                    {
                        EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                            "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
                    }
                }
            }
            StructMemberFlag member_flags_args = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_args = 0x00000001;
            bool common_args_ec {false};
            CommonStructMember common_args {TypeObjectUtils::build_common_struct_member(member_id_args, member_flags_args, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_args, common_args_ec))};
            if (!common_args_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure args member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_args = "args";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_args;
            ann_custom_DdsRecorderCommand.reset();
            CompleteMemberDetail detail_args = TypeObjectUtils::build_complete_member_detail(name_args, member_ann_builtin_args, ann_custom_DdsRecorderCommand);
            CompleteStructMember member_args = TypeObjectUtils::build_complete_struct_member(common_args, detail_args);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderCommand, member_args);
        }
        CompleteStructType struct_type_DdsRecorderCommand = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderCommand, header_DdsRecorderCommand, member_seq_DdsRecorderCommand);
        if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderCommand, type_name_DdsRecorderCommand.to_string(), type_ids_DdsRecorderCommand))
        {
            EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                    "DdsRecorderCommand already registered in TypeObjectRegistry for a different type.");
        }
    }
}

